package com.woniuxy.controller;

import com.woniuxy.service.EmailService;
import com.woniuxy.utils.ResponseResult;
import com.woniuxy.vo.AppointmentsVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Slf4j
@RestController
@RequestMapping("/medical") // 接口基础路径 /medical/extract
@RequiredArgsConstructor
public class testController {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    @Autowired
    EmailService emailService;


    @GetMapping("/test")  // medical/selectAppByOrCond
    public ResponseResult<String> test(@RequestParam("rediskey") String rediskey){
        redisTemplate.opsForValue().set(rediskey, "value", 10, TimeUnit.SECONDS);
        String[] parts = rediskey.split(":");
        if(parts.length == 5) {
            String userId=  parts[2];
            String date=  parts[3];
            String timeSolt=  parts[4];
            System.out.println(userId+"-"+date+"-"+timeSolt);
        }
        return ResponseResult.success();
    }

    @RequestMapping("/send")
    public ResponseResult<String> sendEmail() {
        emailService.sendToQQEmail("1285161740@qq.com", "subject", "content");
        return  ResponseResult.success("发送成功");
    }
}
